from html.parser import HTMLParser


class MyHtmlParser(HTMLParser):
    """docstring for MyHtmlParser"""

    def error(self, message):
        print("Encountered an error :", message)

    def __init__(self):
        super(MyHtmlParser, self).__init__()
        self.imgArr = []

    def handle_starttag(self, tag, attrs):
        if 'img' == tag:
            print("发现图片-href：", attrs)
            for at in attrs:
                if at[0] == "src":
                    self.imgArr.append(at[1])
            # print(at)

    def handle_endtag(self, tag):
        pass
    # print("Encountered an end tag :", tag)

    def handle_data(self, data):
        pass
    # print("Encountered some data  :", data)
